<!DOCTYPE html>
<html>
<head>
<title>regist01.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
	function getXhr() {
		var xhr = null;
		if (window.XMLHttpRequest) {
			xhr = new XMLHttpRequest();
		} else {
			xhr = new ActiveXObject("Microsoft.XMLHttp");
		}
		return xhr;
	}

	function check_name(){
		var uname=document.getElementById("uname");
		var uri="check_name.do?uname="+uname.value;
		var xhr=getXhr();
		xhr.onreadystatechange=function(){
			if(xhr.readyState==4 && xhr.status==200){
				document.getElementById("name_msg").innerHTML=xhr.responseText;
			}
		};
		xhr.open("get",encodeURI(uri),true);
		document.getElementById("name_msg").innerHTML="正在检查。。。";
		xhr.send(null);
	}
</script>

</head>

<body>
	<!-- GET方式提交中文用户名进行验证 -->
	<form action="" method="post">
		<fieldset>
			<legend>注册信息</legend>
			用户名：<input name="uname" id="uname" />
			<input type="button" value="检查一下吧" onclick="check_name()" />
			<span id="name_msg" style="color:red;"></span>
			<br/><br/>
			<input type="submit" value="注册" />
		</fieldset>
	</form>
</body>
</html>
